<!DOCTYPE html>
<html>
<head>
    <title>管理员列表</title>
    #parse("sys/header.html")
</head>
<body>
<div id="rrapp" v-cloak>
    <div v-show="showList">
        <div class="grid-btn" style="width: 100%;height: 100px;">
            <div class="form-group col-sm-2" style="width: 240px;">
                <input type="text" class="form-control" v-model="q.username" @keyup.enter="query" placeholder="用户名，只能输入英文、数字" onkeyup="value=value.replace(/[^\a-\z\A-\Z0-9]/g,'')" >
            </div>
            <div class="form-group col-sm-2" style="width: 230px">
                <input type="text" class="form-control" v-model="q.email" @keyup.enter="query" placeholder="邮箱" onkeyup="value=value.replace(/[^\a-\z\A-\Z0-9\@\_\-\.]/g,'')">
            </div>
            <div class="form-group col-sm-2" style="width: 230px">
                <input type="text" class="form-control" v-model="q.mobile" @keyup.enter="query" placeholder="手机号码，只能输入数字" onkeyup="value=value.replace(/[^0-9]/g,'')">
            </div>
            <div class="form-group col-sm-2" style="width: 270px;clear:both;">
                <input type="text" class="form-control" v-model="q.shopName" @keyup.enter="query" placeholder="企业名称，只能输入中英文、数字" onkeyup="value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5]/g,'')" >
            </div>
            <div class="form-group col-sm-2" style="width: 470px;">
            	<a class="btn btn-default" @click="query">查询</a>
	            #if($shiro.hasPermission("sys:user:save"))
	            <a class="btn btn-primary" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</a>
	            #end
	            #if($shiro.hasPermission("sys:user:update"))
	            <a class="btn btn-primary" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>
	            #end
	            #if($shiro.hasPermission("sys:user:resetPassword"))
	            <a class="btn btn-primary" @click="resetPwd"><i class=""></i>&nbsp;重置密码</a>
	            #end
	            #if($shiro.hasPermission("sys:user:delete"))
	            <a class="btn btn-primary" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
	            #end
	       </div>
        </div>
        <table id="jqGrid"></table>
        <div id="jqGridPager"></div>
    </div>

    <div v-show="!showList" class="panel panel-default">
        <div class="panel-heading">{{title}}</div>
        <form class="form-horizontal">
            <div class="form-group">
                <div class="col-sm-2 control-label">用户名</div>
                <div class="col-sm-10">
                    <input id="input_username" type="text" maxlength="20" class="form-control" v-model="user.username"
                           placeholder="登录账号可由6-20位英文字母或数字" onblur="isusername()" onkeyup="value=value.replace(/[^\a-\z\A-\Z0-9]/g,'')"/>
                </div>
            </div>
            <div class="form-group" v-show="showPassword">
                <div class="col-sm-2 control-label">密码</div>
                <div class="col-sm-10">
                    <input id="input_password" type="text" maxlength="20" class="form-control" v-model="user.password"
                           placeholder="密码可由6-20位字母、数字、符号!?@#$%^&* 组合" onblur="ispassword()" onkeyup="value=value.replace(/[^\a-\z\A-\Z0-9\!@#$%^&*?]/g,'')" onpaste="return false"/>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-2 control-label">邮箱</div>
                <div class="col-sm-10">
                    <input id="input_email" type="email" maxlength="30" class="form-control" v-model="user.email"
                           placeholder="邮箱由字母、数字、下划线、连接线、@和.组成" onblur="isemail()" onkeyup="value=value.replace(/[^\a-\z\A-\Z0-9\@\_\-\.]/g,'')"/>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-2 control-label">手机号</div>
                <div class="col-sm-10">
                    <input id="input_mobile" type="text" maxlength="11" class="form-control" v-model="user.mobile"
                           placeholder="请输入11位数的手机号" onblur="ismobile()" onkeyup="value=value.replace(/[^0-9]/g,'')"/>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-2 control-label">角色</div>
                <div class="col-sm-10">
                    <label v-for="role in roleList" class="checkbox-inline">
                        <input type="checkbox" :value="role.roleId" v-model="user.roleIdList">{{role.roleName}}
                    </label>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-2 control-label">状态</div>
                <label class="radio-inline">
                    <input type="radio" name="status" value="0" v-model="user.status"/> 禁用
                </label>
                <label class="radio-inline">
                    <input type="radio" name="status" value="1" v-model="user.status"/> 正常
                </label>
            </div>
            <div class="form-group">
                <div class="col-sm-2 control-label"></div>
                <input id="submitBtn" type="button" class="btn btn-primary" @click="saveOrUpdate" value="确定"/>
                &nbsp;&nbsp;<input type="button" class="btn btn-warning" @click="reload" value="返回"/>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    function isusername() {
        var username = $("#input_username").val().trim();
        if(username.length < 6 && username.length > 0){
            alert("用户名长度至少为6");
            return false;
        }
        return true;
    }

    function isemail(){
        var emailReg=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
        var email = $("#input_email").val().trim();
        if(emailReg.test(email) == false && email.length > 0){
            alert("邮箱格式有误，请重新输入");
            return false;
        }
        return true;
    }

    function ismobile() {
        var mobileReg = /^1[3456789]\d{9}$/;
        var mobile = $("#input_mobile").val().trim();
        if (mobileReg.test(mobile) == false && mobile.length > 0) {
            alert("手机号输入格式有误，请重新输入");
            return false;
        }
        return true;
    }
    function ispassword() {
        var password = $("#input_password").val().trim();
        if(password.length > 0 && password.length < 6){
            alert("密码长度在6~20");
            return false;
        }
    }

</script>
<script src="${rc.contextPath}/js/sys/user.js?_${date.systemTime}"></script>
</body>
</html>